import { defineConfig, loadEnv } from "vite"
import { createVitePlugins } from "./build/createPlugins"
import { createEnv } from "./build/createEnv"
import { resolve } from "path"

// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
  const root = process.cwd()
  const ENV = loadEnv(mode, root)
  const VITE_ENV = createEnv(ENV)
  return {
    plugins: createVitePlugins(VITE_ENV, command === "build"),
    resolve: {
      alias: {
        "@": resolve(root, "./src")
      }
    }
  }
})
